(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  define(['controllers/base/controller', 'views/movimento/index_view', 'views/movimento/form_view', 'models/movimento_model', 'collections/movimento_collection'], function() {
    'use strict';
    var Controller, FormView, IndexView, MovimentoCollection, MovimentoController, MovimentoModel, _ref;
    Controller = require('controllers/base/controller');
    IndexView = require('views/movimento/index_view');
    FormView = require('views/movimento/form_view');
    MovimentoModel = require('models/movimento_model');
    MovimentoCollection = require('collections/movimento_collection');
    return MovimentoController = (function(_super) {
      __extends(MovimentoController, _super);

      function MovimentoController() {
        _ref = MovimentoController.__super__.constructor.apply(this, arguments);
        return _ref;
      }

      MovimentoController.prototype.index = function() {
        this.collection = new MovimentoCollection;
        return this.view = new IndexView({
          collection: this.collection
        });
      };

      MovimentoController.prototype.create = function() {
        this.model = new MovimentoModel;
        this.view = new FormView({
          model: this.model
        });
        return this._setupHistoryBack();
      };

      MovimentoController.prototype.edit = function(params) {
        this.model = new MovimentoModel({
          id: params.id
        });
        this.view = new FormView({
          model: this.model
        });
        return this._setupHistoryBack();
      };

      MovimentoController.prototype._setupHistoryBack = function() {
        var _this = this;
        return this.view.on('model:saved', function() {
          _this.publishEvent('feedback:success', 'Movimento salvo com sucesso');
          return _this.redirectTo({
            url: 'movimento'
          });
        });
      };

      return MovimentoController;

    })(Controller);
  });

}).call(this);
